// test_SS_videoUIDlg.h : header file
//

#pragma once
#include "apSSEngine1.h"
#include "apSSVideoReader.h"
#include "apSSImage.h"
#include "apFFreader.h"
#include "apFFreader.h"
#include "apThread.h"
#include "afxwin.h"

#define START_EVT_NUMBER	3
#define MAX_POINTS			128

// Ctest_SS_videoUIDlg dialog
class Ctest_SS_videoUIDlg : public CDialog, apThread
{
// Construction
public:
	Ctest_SS_videoUIDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_TEST_SS_VIDEOUI_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnBnClickedButtonRun();
	afx_msg void OnDropFiles(HDROP hDropInfo);
	afx_msg void OnBnClickedButtonSelFile();
	afx_msg void OnBnClickedButtonSelSrc();
	afx_msg void OnBnClickedButtonLearnSrc();
	afx_msg void OnBnClickedButtonLoadMod();
	afx_msg void OnBnClickedButtonSaveMod();
	afx_msg void OnBnClickedButtonSelmodel();
	afx_msg void OnBnClickedRadioModePic();
	afx_msg void OnBnClickedRadioModeFile();
	afx_msg void OnBnClickedButtonLearnHolder();
	afx_msg void OnBnClickedButtonPlay();
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnBnClickedButtonGenShape();
	afx_msg void OnBnClickedButtonOpenSrcMark();
	afx_msg void OnBnClickedButtonStartMark();
	afx_msg void OnClose();
	afx_msg void OnBnClickedButtonStartLearnSrc();
	afx_msg void OnBnClickedButtonSavePic();
	afx_msg void OnBnClickedButtonDisPic();
	afx_msg void OnBnClickedButtonOpenClip();
	afx_msg void OnBnClickedButtonCleanAllShape();
	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnBnClickedButtonMarkFullShape();
	afx_msg void OnCbnSelchangeComboLearnWhat();
	afx_msg void OnBnClickedButtonSetEng();
private:
	int					m_mode;//0-pic, 1-file
	apSSEngine1			m_eng;
	apSSVideoReader 	m_reader;
	apFFreader			m_readerFF;
	int					m_clipWidth;
	int					m_clipHeight;
	bool				m_bDoRec;
	HANDLE				m_StopEvt;
	HANDLE				m_StartEvt[START_EVT_NUMBER];//0-learn, 1-save model, 2-recognize
	bool				m_playing;
	bool				m_opened;
	CPoint				m_points[50];
	HSEShape			m_shapes[16];
	int					m_shape_cnt;
	int					m_pointCnt;
	bool				m_bMark;
	int					m_bmWidth;
	int					m_bmHeight;

private:
	void ProcessImg(HBITMAP hBMP);
	void DrawImg(CDC *pDC, HBITMAP hBMP, int x, int y, 
		int SrcWidth, int SrcHeight, int DesWidth, int DesHeight);
	void DoLearn();
	void DoSaveModel();
	void DoRecognize();
	void LearnBackground();
	void LearnHolder();
	void SelBackground();
	void SelHolder();
	void FF_learn();
	void DShow_learn();
	void FF_recognize();
	void DShow_recognize();
protected:
	virtual void thread_proc();

public:
	CComboBox m_combo_learn_what;
	CComboBox m_combo_type;
};

